{% extends "base.html" %}

{% block title %}作业管理{% endblock %}
{% block page_title %}作业管理{% endblock %}

{% block content %}
<div class="card mb-4">
    <div class="card-header">
        <h5 class="mb-0">发布新作业</h5>
    </div>
    <div class="card-body">
        <form method="post">
            {% csrf_token %}
            <input type="hidden" name="create_homework" value="1">
            <div class="row g-3">
                <div class="col-md-4">
                    <label class="form-label">科目</label>
                    <input type="text" name="subject" class="form-control" required>
                </div>
                <div class="col-md-8">
                    <label class="form-label">作业标题</label>
                    <input type="text" name="title" class="form-control" required>
                </div>
                <div class="col-12">
                    <label class="form-label">作业内容</label>
                    <textarea name="content" class="form-control" rows="3" required></textarea>
                </div>
                <div class="col-md-6">
                    <label class="form-label">截止日期</label>
                    <input type="datetime-local" name="due_date" class="form-control" required>
                </div>
                <div class="col-md-6 d-flex align-items-end">
                    <button type="submit" class="btn btn-primary w-100">
                        <i class="fas fa-plus me-1"></i>发布作业
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="card">
    <div class="card-header">
        <h5 class="mb-0">已发布作业</h5>
    </div>
    <div class="card-body">
        {% if homeworks %}
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>科目</th>
                        <th>标题</th>
                        <th>截止日期</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for hw in homeworks %}
                    <tr>
                        <td>{{ hw.subject }}</td>
                        <td>{{ hw.title }}</td>
                        <td>{{ hw.due_date }}</td>
                        <td>
                            <a href="#" class="btn btn-sm btn-outline-primary">
                                <i class="fas fa-eye me-1"></i>查看提交
                            </a>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% else %}
        <div class="alert alert-info mb-0">尚未发布任何作业</div>
        {% endif %}
    </div>
</div>
{% endblock %}